﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Reflection;
using System.Web.Routing;


namespace HelloMVC.Injection
{
    public class PIMControllerFactory : DefaultControllerFactory
    {
        #region Member Vars
        private readonly DependencyInjectHandler _diHandler;
        #endregion
        #region Constructors

        public PIMControllerFactory(DependencyInjectHandler diHandler)
        {
            _diHandler = diHandler;
            _diHandler.RegisterControllersInAssemblly(Assembly.GetExecutingAssembly());
        }
        #endregion
        #region Public Methods
        protected override IController GetControllerInstance(RequestContext requestContxt, Type controllerType)
        {
            return _diHandler.GetControllerInstance(controllerType);
        }
        #endregion
    }
}
